#include "NonLocal.h"
#include "IVisitor.h"

NonLocal::NonLocal(const NameTokList& names, const exprTypePtr& value, int nodeId):
    stmtType(nodeId),
    _names(names),
    _value(value)
{
}
    
NonLocal::~NonLocal()
{
    _names.clear();
}
    
QString NonLocal::type() const
{
    return "NonLocal";
}
    

NameTokList NonLocal::names()
{
    return _names;
}

void NonLocal::setNames(const NameTokList& names)
{
    _names = names;
}

exprTypePtr NonLocal::value()
{
    return _value;
}

void NonLocal::setValue(const exprTypePtr& value)
{
    _value = value;
}

    
QString NonLocal::toString() const
{
    return QString("NonLocal[names=%1, value=%2]").
                arg(_names.toString()).
                arg(_value ? _value->toString():"");
}
    
void NonLocal::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitNonLocal(node.dynamicCast<NonLocal>());
}
    
void NonLocal::traverse(IVisitor* visitor)
{
    _names.traverse(visitor);
    if (_value != NULL)
        _value->accept(visitor, _value);
}